﻿Namespace PL.MetaSDK 'Processing Layer

    Public Class MetaStringLocals_PL
        Inherits PLBase
        Implements IPLProcess

        Public Sub New()
        End Sub

        Public Sub New(ByVal queryName As String)
            MyBase.New(queryName)
        End Sub

        Public Overrides Function Delete() As Boolean
            Return True
        End Function

        Public Overrides Function Validate() As Boolean
            Return True
        End Function

        Public Overrides Sub ValidateRow(row As DataRow)
            row.ClearErrors()
            'Mandatory Fields
            'TODO: Cache MetaString in AppManager, so here we read it once maybe for nothing
            'Dim ms As MetaString
            'ms = MetaString.GetMetaStringByCode("Mandatory", AppManager.ApplicationOption.LanguageId)
            If IsDBNull(row("StringLocalID")) Then
                row.SetColumnError("StringLocalID", "Mandatory")
            End If
            '
            If IsDBNull(row("StringID_FK")) Then
                row.SetColumnError("StringID_FK", "Mandatory")
            End If
            '
            If IsDBNull(row("LanguageStringID_FK")) Then
                row.SetColumnError("LanguageStringID_FK", "Mandatory")
            End If
            '
            If IsDBNull(row("StringLocal")) Then
                row.SetColumnError("StringLocal", "Mandatory")
            End If
            '
            If IsDBNull(row("Customize")) Then
                row.SetColumnError("Customize", "Mandatory")
            End If
            '
            If IsDBNull(row("SystemRecord")) Then
                row.SetColumnError("SystemRecord", "Mandatory")
            End If
            '
            If row.HasErrors Then
                row.RowError = "Please check your columns, a validation error occur"
            End If
        End Sub

        Public Function BatchRecords(dataRow() As DataRow) As Boolean Implements IPLProcess.BatchRecords
            Return True
        End Function

        Public Function CurrentRecord(dataRow As DataRow) As Boolean Implements IPLProcess.CurrentRecord
            Return True
        End Function

        Public Function NewRecord(dataRow As DataRow) As Boolean Implements IPLProcess.NewRecord
            dataRow("StringLocalID") = Guid.NewGuid()
            dataRow("SystemRecord") = 1
            dataRow("Customize") = 1
            Return True
        End Function
    End Class
End Namespace
